package com.yimi.policyservice.repository;

import com.yimi.policyservice.entity.base.policy.PolicyComminsureItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface PolicyComminsureItemRepository extends JpaRepository<PolicyComminsureItem,String> {

    @Query(value = "SELECT  * from t_policy_comminsure_item item where item.product_id =?1 order by item.order_index ",nativeQuery = true)
    List<PolicyComminsureItem> findByProductId(String id);

    @Transactional
    @Modifying
    @Query(value = "delete from  t_policy_comminsure_item where product_id in ?1",nativeQuery = true)
    void deleteByProdictIdIn(List<String> ids);
}
